package com.mall.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mall.entity.SmsCouponCategory;
import com.mall.mapper.SmsCouponCategoryMapper;
import com.mall.service.SmsCouponCategoryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class SmsCouponCategoryServiceImpl extends ServiceImpl<SmsCouponCategoryMapper, SmsCouponCategory>  implements SmsCouponCategoryService {

    @Resource
    private SmsCouponCategoryMapper smsCouponCategoryMapper;

    @Override
    public SmsCouponCategory getById(Integer id) {
        return smsCouponCategoryMapper.selectById(id);
    }

    @Override
    public List<SmsCouponCategory> getAll() {
        return smsCouponCategoryMapper.selectList(null);
    }

    @Override
    public boolean deleteById(Integer id) {
        return smsCouponCategoryMapper.deleteById(id) > 0;
    }

    @Override
    public boolean save(SmsCouponCategory smsCouponCategory) {
        if(smsCouponCategory.getId() == null)
        {
            return smsCouponCategoryMapper.insert(smsCouponCategory) > 0;
        }else{
            return  smsCouponCategoryMapper.updateById(smsCouponCategory) > 0;
        }
    }
}
